import 'dart:io';
import 'package:elevator/widgets/globel_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';

import 'operate_logic.dart';

class OperatePage extends StatelessWidget {
  String title;
  late OperateLogic logic;

  OperatePage({Key? key, required this.title,required errorData}) : super(key: key){
    Get.delete<OperateLogic>();
    logic = Get.put(OperateLogic());
    logic.errorData = errorData;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        // appBar: myAppbar(
        //   actions: [
        //     IconButton(
        //       icon: const Icon(
        //         Icons.person,
        //         size: 36,
        //       ),
        //       onPressed: () {},
        //     ),
        //   ],
        // ),
      appBar: AppBar(),
        body: Container(
          child: Stack(children: [
            Container(
              decoration: const BoxDecoration(
                image: DecorationImage(
                  image: AssetImage('images/app_bg.png'),
                  fit: BoxFit.cover,
                ),
              ),
            ),
            SingleChildScrollView(
              child: Container(
                padding: EdgeInsets.all(16),
                child:
                  Column(
                    children: [
                      // 白线
                      Container(
                        width: double.infinity,
                        height: 1,
                        color: Colors.white,
                      ),
                      Row(
                        children: [
                          // 白线
                          Container(
                            width: 1,
                            height: 48,
                            color: Colors.white,
                          ),
                          const Expanded(
                            child: Text("CPU",
                              textAlign: TextAlign.center,
                              style: TextStyle(color: Colors.white),
                            ),
                          ),
                          // 白线
                          Container(
                            width: 1,
                            height: 48,
                            color: Colors.white,
                          ),
                          const Expanded(
                            child: Text("Error",
                              textAlign: TextAlign.center,
                              style: TextStyle(color: Colors.white),
                            ),
                          ),
                          // 白线
                          Container(
                            width: 1,
                            height: 48,
                            color: Colors.white,
                          ),
                        ],
                      ),
                      // 白线
                      Container(
                        width: double.infinity,
                        height: 1,
                        color: Colors.white,
                      ),
                      Row(
                        children: [
                          // 白线
                          Container(
                            width: 1,
                            height: 48,
                            color: Colors.white,
                          ),
                          Expanded(
                            child: Text(logic.getCpu(),
                              textAlign: TextAlign.center,
                              style: TextStyle(color: Colors.white),
                            ),
                          ),
                          // 白线
                          Container(
                            width: 1,
                            height: 48,
                            color: Colors.white,
                          ),
                          Expanded(
                            child: Text(logic.getError(),
                              textAlign: TextAlign.center,
                              style: TextStyle(color: Colors.white),
                            ),
                          ),
                          // 白线
                          Container(
                            width: 1,
                            height: 48,
                            color: Colors.white,
                          ),
                        ],
                      ),
                      // 白线
                      Container(
                        width: double.infinity,
                        height: 1,
                        color: Colors.white,
                      ),
                      // 四周白色边框，内容未图片
                      IntrinsicHeight(child: Container(
                  // color: Colors.green,
                      padding: const EdgeInsets.all(8),
                      child: Obx(() {
                          return Column(
                            children: [
                              if(""==logic.imgPath.value)
                                Text(logic.msg.value),
                              if(""!=logic.imgPath.value)
                                Expanded(child: InteractiveViewer(
                                  minScale: 0.1,
                                  maxScale: 4.0,
                                  child: Image.file(File(logic.imgPath.value)),
                                )
                                )
                            ],
                          );
                        }),
                      ),)

                    ],
                  )
                // Text(
                //   '$title(410B)操做指导',
                //   style: const TextStyle(color: Colors.white),
                // ),
              ),
            )
          ]),
        ));
  }
}
